package com.changgou.search.controller;

import com.changgou.search.service.SkuService;
import com.changgou.util.Result;
import com.changgou.util.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author tang.qingbo
 * @Date 2020/8/28 13:53
 * @Version 1.0
 */
@RequestMapping("/search")
@RestController
@CrossOrigin//开启跨域
public class SkuController {

    @Autowired
    private SkuService skuService;

    /**
     * 导入sku数据
     */
    @GetMapping("/import")
    public Result importSku() {
        skuService.importSku();
        return new Result(true, StatusCode.OK, "导入sku数据成功");
    }

    /**
     * 搜索
     */
    @GetMapping
    public Map search(@RequestParam(required = false) Map<String, String> searchMap) {
        return skuService.search(searchMap);
    }
}
